import { Input } from "antd";
import { useState } from "react";
interface Com2Props {
  children?: React.ReactNode;
  valueChange: (e: string,flog:Boolean) => void;
}
const Com2: React.FC<Com2Props> = (props) => {
  const [value, UseValue] = useState("");
  const { valueChange, children } = props;
  const valueUpdate = (e: any) => {
    const str = e.target.value;
    UseValue(str);
    const flog = children ? true : false
    valueChange(str, flog);
  };
  return (
    <div style={{ display: "flex", alignItems: "center" }}>
      {children}
      <Input
        value={value}
        onChange={valueUpdate}
        placeholder={`输入内容，改变${children ? "组件一" : "父组件"}的值`}
      ></Input>
    </div>
  );
};

export default Com2;
